<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Model;



/**
 * @property int $id
 * @property int $user_id
 * @property int $article_id
 */
class ArticleLike extends Model
{
    public bool $timestamps = false;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'article_like';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = [];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'user_id' => 'integer', 'article_id' => 'integer'];

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }
    public function article()
    {
        return $this->belongsTo(Article::class, 'article_id', 'id');
    }

    // 如果你需要隐藏原始的 create_time 字段
    protected array $hidden = ['create_time'];

    // 如果你需要显示新的 createTime 字段
    protected array $appends = ['createTime'];


    // 获取 createTime 属性
    public function getCreateTimeAttribute()
    {
        return $this->attributes['create_time'];
    }

}
